﻿using System;
using iPdf.Properties;
using Elegant.Ui;

namespace iPdf
{
    class VistaStyleFitToScreenButton : Button
    {
        static VistaStyleFitToScreenButton()
        {
            AddSkin();
        }

        private static void AddSkin()
        {
            if (!SkinManager.ContainsProduct("Vista"))
                SkinManager.AddProduct("Vista");

            Glyph test;
            if (!SkinManager.TryGetGlyph("VistaStyleFitToScreenButton.Normal", out test)) // For VS designer to open more then once.
            {
                TextureGlyph glyph = (TextureGlyph)SkinManager.AddNewGlyph("Vista", typeof(TextureGlyph), "VistaStyleFitToScreenButton.Normal");
                glyph.Texture = Resources.FitToScreenButtonNormal;

                glyph = (TextureGlyph)SkinManager.AddNewGlyph("Vista", typeof(TextureGlyph), "VistaStyleFitToScreenButton.Hovered");
                glyph.Texture = Resources.FitToScreenButtonHovered;

                glyph = (TextureGlyph)SkinManager.AddNewGlyph("Vista", typeof(TextureGlyph), "VistaStyleFitToScreenButton.Pressed");
                glyph.Texture = Resources.FitToScreenButtonPressed;

                glyph = (TextureGlyph)SkinManager.AddNewGlyph("Vista", typeof(TextureGlyph), "VistaStyleFitToScreenButton.Disabled");
                glyph.Texture = Resources.FitToScreenButtonDisabled;

                SkinManager.AddNewSkin("Vista", typeof(ButtonSkin), "VistaStyleFitToScreenButton");
            }
        }

        public VistaStyleFitToScreenButton()
        {
            Size = Resources.FitToScreenButtonNormal.Size;
        }


        /// <summary>
        /// This item supports the framework infrastructure and is not intended to be used directly from your code.
        /// </summary>
        protected override void OnSkinChanged(EventArgs e)
        {
            base.OnSkinChanged(e);

            Skin.GetPaintInformation(ButtonState.Normal).BackgroundGlyphName = "VistaStyleFitToScreenButton.Normal";

            Skin.GetPaintInformation(ButtonState.Hovered).BackgroundGlyphName = "VistaStyleFitToScreenButton.Hovered";

            Skin.GetPaintInformation(ButtonState.Pressing).BackgroundGlyphName = "VistaStyleFitToScreenButton.Pressed";

            Skin.GetPaintInformation(ButtonState.Disabled).BackgroundGlyphName = "VistaStyleFitToScreenButton.Disabled";

            Skin.GetPaintInformation(ButtonState.Default).BackgroundGlyphName = "VistaStyleFitToScreenButton.Normal";
            Skin.GetPaintInformation(ButtonState.DefaultFocused).BackgroundGlyphName = "VistaStyleFitToScreenButton.Normal";
            Skin.GetPaintInformation(ButtonState.DefaultHovered).BackgroundGlyphName = "VistaStyleFitToScreenButton.Hovered";
            Skin.GetPaintInformation(ButtonState.DefaultPressing).BackgroundGlyphName = "VistaStyleFitToScreenButton.Pressed";
            Skin.GetPaintInformation(ButtonState.Focused).BackgroundGlyphName = "VistaStyleFitToScreenButton.Hovered";
        }

        /// <summary>
        /// Overrides the member from the base class.
        /// </summary>
        public override string ContextId
        {
            get { return "VistaStyleFitToScreenButton"; }
        }
    }
}